<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j">
	<ui:define name="stylefms">
		<link href="/stylesheet/theme.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/fms.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/panel.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/debug.css" rel="stylesheet" type="text/css" />
	</ui:define>
	<ui:define name="varProjectName">
		<ui:param name="projectName" value="#{appRes['mod.fms.prd.maintenances.insumos']}" />
	</ui:define>


	<ui:define name="body">
		<a4j:form id="SuppliesForm" ajaxSingle="true">
			<div class="mainForm">
			<rich:panel styleClass="form">
				
				<h:panelGrid>
					<div class="attributes">
						<h:panelGrid>
						
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Codigo</ui:define>
								<h:inputText value="#{editSupplies.supplies.cod}"
									id="SuppliesCode" 
									required="true" size="5"
									requiredMessage="Favor introduzca un codigo"
									validatorMessage="El codigo no puede ser menor a 1 o mayor a 5">
									<f:validateLength minimum="1" maximum="5" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="SuppliesCode"/>
								</div>
							</s:decorate>
							<div style="clear: both;" />
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Descripcion</ui:define>
								<h:inputText value="#{editSupplies.supplies.descrip}" label="Descripcion"
									id="SuppliesDescrip" 
									required="true" size="30"
									requiredMessage="Favor introduzca el nombre de la descripcion"
									validatorMessage="El nombre no puede ser menor a 1 o mayor a 50">
									<f:validateLength minimum="1" maximum="50" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="SuppliesDescrip"/>
								</div>
							</s:decorate>
							<div style="clear: both;" />
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Insumo Tipo</ui:define>
								<h:selectOneMenu  value="#{editSupplies.supplies.suppliesTypeData}" label="Descripcion"
									id="SuppliesType" 
									required="true"
									requiredMessage="Seleccione el tipo de insumo"
									converter="#{suppliesTypeConverter}">
									<a4j:support event="onblur" />
									<s:selectItems var="sType" value="#{withinHolder.suppliesTypeList()}" label="#{sType.descrip}"></s:selectItems>
									
								</h:selectOneMenu>
								<div class="msg_container">
								<rich:message for="SuppliesType"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Proveedor</ui:define>
								<h:selectOneMenu  value="#{editSupplies.supplies.supplierData}" label="Descripcion"
									id="Supplier" 
									required="true"
									requiredMessage="Seleccione el Proveedor"
									converter="#{supplierConverter}">
									<a4j:support event="onblur" />
									<s:selectItems var="prov" value="#{withinHolder.supplierList()}" label="#{prov.cod}"></s:selectItems>
									
								</h:selectOneMenu>
								<div class="msg_container">
								<rich:message for="Supplier"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Iva</ui:define>
								<h:selectOneMenu  value="#{editSupplies.supplies.taxData}" label="Descripcion"
									id="Tax" 
									required="true"
									requiredMessage="Seleccione el IVA"
									converter="#{taxConverter}">
									<a4j:support event="onblur" />
									<s:selectItems var="tax" value="#{withinHolder.taxesList()}" label="#{tax.cod}"></s:selectItems>
									
								</h:selectOneMenu>
								<div class="msg_container">
								<rich:message for="Tax"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Activo</ui:define>
								<h:selectBooleanCheckbox value="#{editSupplies.supplies.status}" id="SuppliesStatus"
								required="false" 
								validatorMessage="El estado no puede ser menor o mayor a 1"
								disabled="true">
								<a4j:support event="onblur" />
								</h:selectBooleanCheckbox>
								
								<div class="msg_container">
									<rich:message for="SuppliesStatus"/>
								</div>
							</s:decorate>				
							<div style="clear: both;" />
							 
						</h:panelGrid>
					</div>
					
				</h:panelGrid>
			</rich:panel>
			</div>
			<div class="twoColumns">
				<div class="left">
					<a4j:form id="SuppliesCostGridForm" ajaxSingle="true">
						<rich:panel styleClass="table_back">
							<rich:datascroller align="center" for="SuppliesCostGrid"
								maxPages="15" page="#{dataTableScrollerBean.scrollerPage}"
								renderIfSinglePage="false" />
								
							<rich:dataTable id="SuppliesCostGrid"
								value="#{editSupplies.allSupplies}" var="supplies" rows="5"
								rendered="#{not empty editSupplies.allSupplies}">
								
								<rich:column>
									<f:facet name="header">Codigo</f:facet>
									<h:outputText value="#{supplies.cod}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Descripcion</f:facet>
									<h:outputText value="#{supplies.descrip}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Activo</f:facet>
									<h:outputText value="#{convertAssist.booleanToString(supplies.status)}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Activo</f:facet>
									<h:outputText value="#{convertAssist.booleanToString(supplies.operateStock)}" />
								</rich:column>
			
							</rich:dataTable>
						</rich:panel>
						
					</a4j:form>
				</div>
				<div class="right">
					<rich:panel styleClass="form">
				
						<h:panelGrid>
							<div class="attributes">
								<h:panelGrid columns="1">
								
									<s:decorate template="/layout/input.xhtml">
										<ui:define name="label">Rubro</ui:define>
										<h:selectOneMenu  value="#{editSupplies.supplies.burdenData}" label="Descripcion"
											id="Burden" 
											required="false"
											requiredMessage="Seleccione el Rubro"
											converter="#{burdenConverter}">
											<a4j:support event="onblur" />
											<s:selectItems var="bur" value="#{withinHolder.burdenList()}" label="#{bur.descrip}"></s:selectItems>
											
										</h:selectOneMenu>
										<div class="msg_container">
										<rich:message for="Burden"/>
										</div>
									</s:decorate>
									<div style="clear: both;" />
									
									<s:decorate template="/layout/input.xhtml">
										<ui:define name="label">Grupo</ui:define>
										<h:selectOneMenu  value="#{editSupplies.supplies.groupData}" label="Descripcion"
											id="Group" 
											required="false"
											requiredMessage="Seleccione el Grupo"
											converter="#{groupConverter}">
											<a4j:support event="onblur" />
											<s:selectItems var="gr" value="#{withinHolder.groupList()}" label="#{gr.descrip}"></s:selectItems>
											
										</h:selectOneMenu>
										<div class="msg_container">
										<rich:message for="Group"/>
										</div>
									</s:decorate>
									<div style="clear: both;" />
									
									<s:decorate template="/layout/input.xhtml">
										<ui:define name="label">Family</ui:define>
										<h:selectOneMenu  value="#{editSupplies.supplies.familyData}" label="Descripcion"
											id="Family" 
											required="false"
											requiredMessage="Seleccione la Familia"
											converter="#{familyConverter}">
											<a4j:support event="onblur" />
											<s:selectItems var="fm" value="#{withinHolder.familyList()}" label="#{fm.descrip}"></s:selectItems>
											
										</h:selectOneMenu>
										<div class="msg_container">
										<rich:message for="Family"/>
										</div>
									</s:decorate>
									<div style="clear: both;" />
									
									<s:decorate template="/layout/input.xhtml">
										<ui:define name="label">Maneja Existencia</ui:define>
										<h:selectBooleanCheckbox value="#{editSupplies.supplies.operateStock}" id="OperateStock"
										required="false" >
										<a4j:support event="onblur" />
										</h:selectBooleanCheckbox>
										<div class="msg_container">
										<rich:message for="OperateStock"/>
										</div>
									</s:decorate>
									
									
									 
								</h:panelGrid>
							</div>	
						</h:panelGrid>
					</rich:panel>
				</div>

			</div>
			<div class="formActions">
				<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form">
					<a4j:commandButton value="Guardar"
						action="#{editSupplies.saveNewData()}" reRender="SuppliesForm, SuppliesCostGridForm" styleClass="button"/>
					<rich:spacer width="20px" />
					<a4j:commandButton value="Cancelar"
						action="#{editSupplies.cancelData()}" reRender="SuppliesForm, SuppliesCostGridForm" styleClass="button" />
				</s:decorate>
			</div>
		</a4j:form>


	</ui:define>

</ui:composition>